﻿$(document).ready(function() {
    $('.boxcomment').textareaAutoSize();
    
    $('.fr-postnewstatus').submit(function () {
        App.blockUI($("body"));
    });
    
    $('.fr-comment').submit(function () {
        var id = $(this).attr("data-id");
        var block = $(".postcomment" + id);
        App.blockUI(block);
        $.ajax({
            url: '/post/postcomment',
            data: $(this).serialize(),
            method: "POST",
            success: function (data) {
                $(".listcomment" + id).html(data);
                $("#areacomment" + id).val("");
                App.unblockUI(block);
            }
        });
        return false;
    });

});

function seeallcomments(postid) {
    var block = $(".postcomment" + postid);
    App.blockUI(block);
    $.ajax({
        url: '/post/getallcomment?postid=' + postid,
        success: function (data) {
            $(".listcomment" + postid).html(data);
            App.unblockUI(block);
        }
    });
}

function deletecomment(commentid, postid) {
    if (confirm("Are you sure delete this comment?")) {
        var block = $(".postcomment" + postid);
        App.blockUI(block);
        $.ajax({            
            url: "/post/deletecomment",
            data:{commentid : commentid, postid:postid},
            success:function(data) {
                $(".listcomment" + postid).html(data);
                App.unblockUI(block);
            }
        });
    }
}